#include "LogStatusDAO.h"
#include "Log.h"
#include "DAOProxy.h"
#include "ConfigJsonTable.h"

LogStatusDAO::LogStatusDAO()
{
	_name = "Common_LogBaseConfig";
}

bool LogStatusDAO::update()
{
	
    QLOG_DEBUG("%s","start update LogStatus");
	//Config::ConfigRecordSet recordset;
	string datastr;

	try{
		ConfigMasterPrx & master = ConfigClientObj.getMasterPrx();
		master->query("select * from Common_LogBaseConfig;",datastr);
	}
	catch(Config::Error & ex)
	{
		QLOG_DEBUG("%s",ex.reason);
		return false;
	}
	catch(const Ice::Exception & ex)
	{
		QLOG_DEBUG("%s",ex.what());
		return false;
	}

	Config::ConfigJsonTable recordset;
	recordset.read(datastr);
	QLOG_DEBUG("%s",recordset.toStyledString().c_str());

	recordset.moveFirst();
	while(recordset.more())
	{
		LogImplObj.setPattern(recordset.getString("LogPattern"));
		LogImplObj.setLogSwitch(recordset.getInt("LogSwitch"));
		LogImplObj.setFileSwitch(recordset.getInt("LogFileSwitch"));
		LogImplObj.setConsoleSwitch(recordset.getInt("LogConsoleSwitch"));
		LogImplObj.setRotion(recordset.getString("Rotion")); 
		QLOG_DEBUG("  -------%s",recordset.getString("LogPattern").c_str());
		recordset.moveNext();
	}

	return true;
}


bool LogStatusDAO::build()
{
   

	return true;
}
